<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of verejne
 *
 * @author abc
 */

namespace application;

class kontakty extends commonabstract {
    
    private $data = false;
    
    public function home($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        $this->data['contents'] = $this->appmodel->contents($this->app, $this->appaction, $appparams);
    }
    
    public function pridat($appparams) {
        if ($appparams <> $this->appparams) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        $args = array('jmenofield' => FILTER_SANITIZE_ENCODED, 'phonefield' => FILTER_SANITIZE_NUMBER_INT, 'emailfield' => FILTER_VALIDATE_EMAIL, 'textfield' => FILTER_SANITIZE_ENCODED);
        $temppost = \system\getpost::get($args);
//        dump($temppost);
        $this->data['webname'] = $this->appmodel->webname();
        $this->data['info'] = $this->appmodel->info();
        $this->data['footer'] = $this->appmodel->footer();
        $this->data['sidebar'] = $this->appmodel->sidebar();
        $this->appmodel->addkontakt($temppost, $appparams);
//        $this->data['contents'] = $this->appmodel->contents($this->app, $this->appaction, $appparams);
    }
        
    public function getappdata($appaction) {
        if ($appaction <> $this->appaction) : throw new Exception('Nemáte oprávnění! Zjištěna změna dat!', 6);
        endif;
        $this->$appaction($this->appparams);
        return $this->data;
    }
}
